# SPDX-License-Identifier: GPL-2.0-only
# Copyright(c) 2019 Huawei Technologies Co., Ltd.
# CONFIG_MODULE_SIG=n

BUILD ?= /lib/modules/`uname -r`/build
TARGET = cman
cman-objs := cman_drv.o platform_info.o hw_regs_access.o
obj-m := $(TARGET).o
EXTRA_CFLAGS += -Wall -Werror -Wno-unused-function -I./

ifeq ($(CC), $(filter $(CC), gcc cc))
EXTRA_CFLAGS += -fno-ipa-sra -fno-ipa-cp
endif

DEBUG ?= 0
ifeq ($(DEBUG), 1)
	EXTRA_CFLAGS += -DDEBUG
endif

.PHONY : all
all:
	$(MAKE) -C $(BUILD) M=$(PWD) modules

.PHONY : clean
clean:
	$(MAKE) -C $(BUILD) M=$(PWD) clean

.PHONY : install
install:
	sudo rmmod -s cman || true
